#include "proc/cpu.h"
#include "riscv.h"
#include "lib/lock.h"

static cpu_t cpus[NCPU];

cpu_t* mycpu(void)
{
  int id = mycpuid();
  struct cpu *c = &cpus[id];
  return c;
}

int mycpuid(void) 
{
  int id = r_tp();
  return id;
}

proc_t* myproc(void)//获取当前CPU的cpu->proc结构体条目
{
  push_off();
  struct cpu *c = mycpu();
  struct proc *p = c->proc;
  pop_off();

  return p;
}